package com.design.pattern.builder;

import lombok.Getter;
import lombok.Setter;

/**
 * @author 王霄
 * @date 2022/6/14 14:18
 */
@Getter
@Setter
public class Robot {

    /**
     * 名称
     */
    private String name;
    /**
     * 头
     */
    private Header header;
    /**
     * 身体
     */
    private Body body;
    /**
     * 腿
     */
    private Leg leg;
    /**
     * 脚
     */
    private Foot foot;

    public static Builder builder() {
        return new Builder(new Robot());
    }

    public static class Builder {

        private final Robot robot;

        public Builder(Robot robot) {
            this.robot = robot;
        }

        public Builder name(String name) {
            robot.name = name;
            return this;
        }

        public Header.Builder headerBuilder() {
            return new Header.Builder(robot);
        }


        public Body.Builder bodyBuilder() {
            return new Body.Builder(robot);
        }


        public Leg.Builder legBuilder() {
            return new Leg.Builder(robot);
        }


        public Foot.Builder footBuilder() {
            return new Foot.Builder(robot);
        }

        public Robot build() {
            return robot;
        }
    }
}
